/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session.TX;

import entity.Users;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Lu Xiaodi
 */
@Stateless
public class UsersSB implements UsersSBRemote{

    @PersistenceContext()
    EntityManager em;
    
    public UsersSB(){
        
    }
    
    public void createUser(Long id, String email){
        Users user = new Users();
        user.setId(id);
        user.setEmail(email);
        em.persist(user);
    }
    
    public List<Users> getAllUser(){
        Query query = em.createQuery("Select u from Users AS u");
        return query.getResultList();
    }
    
}
